var num = 40;//后端传
var id = 0;
function jump(id) {
  window.open("./html/WorksOne.html?id=" + id, "_blank");
}
$ajax({
  method: "GET",
  url: "http://39.97.237.157:8081/api/fourpro",
  success: function (result) {
    console.log(result); 
    var img1 = document.getElementById("firstImg");
    console.log(img1);
    img1.src = result.data[0].cover;
    console.log(img1);
    var img2 = document.getElementById("secondImg");
    console.log(img2);
    img2.src = result.data[1].cover;
    console.log(img2);
    var img3 = document.getElementById("thirdImg");
    console.log(img3);
    img3.src = result.data[2].cover;
    var img4 = document.getElementById("forthImg");
    console.log(img4);
    img4.src = result.data[3].cover;
  }
})
$ajax({
  method: "GET",
  url: "http://39.97.237.157:8081/api/getallarticlesbyhot",
  success: function (result) {
    console.log(result);
    console.log(result.data.length);
    var j = result.data;

    for (var i = 0; i < j.length; i++) {
      // id++;
      console.log( j[i].name[2])
      if(j[i].proName.length>6){
        var deletName = j[i].proName[0]+j[i].proName[1]+j[i].proName[2]+j[i].proName[3]+'.....'
      }else{
        deletName = j[i].proName;
      }
      
      $('.works').append('<div class="col-md-3 Work"> <div class="thumbnail workOne" onclick="jump(' + j[i].proId + ');" id="' + j[i].proId + '"><p class="workname">' +deletName+ '</p><img alt="300x200" src="' + j[i].cover + '" class="images" /><div class="caption"> <div class="zanTime"><p class="zan">&#10084;</p><p class="zanShu">' + j[i].lNumber + '</p></div> <div class="nameID"><span><img alt="12x12" src="' + '../资源文件/img/WorksShow柯南.jpeg' + '"class="img-circle touxiang" />' +  j[i].name + '</span> </div> </div> </div> </div>');
        // var path = '${base.contextPath}/resources/images/'+areaCode.replace("#","")+".png";
      // var path = '钢炼.jpg'' + j[i].cover+ '
      // $(".workOne").css("background-image", "url(" + path + ")").css(" background-repeat", "no-repeat").css('background-size', '100% 100%');
    }   //<div class="col-md-3 Work"> <div class="thumbnail workOne" onclick="jump(' + j[i].id + ');" id="' + id + '"><p class="workname">' + j[i].title + '</p><img alt="300x200" src="' + j[i].cImg+ '" class="images" /><div class="caption"> <div class="zanTime"><p class="zan">&#10084;</p><p class="zanShu">' + j[i].lNumber + '</p></div> <div class="nameID"><span><img alt="12x12" src="' + touxiang + '"class="img-circle touxiang" />' + j[i].author + '</span> </div> </div> </div> </div>'
  }
})   
$ajax({
  method: "GET",
  url: "http://39.97.237.157:8081/api/getcatch",
  success: function (result) {
    console.log(result); 
    var z= result.data;
    for(var l=0;l<z.length;l++){
      $('#catch').append('<hr><div class="media"><div class="media-left media-middle"><img src="'+z[l].gCImg+'" class="media-object images" "></div><div class="media-body"><h4 class="media-heading">'+z[l].gName+'</h4><p>'+z[l].gIntro+'</p></div></div>')
    }         
  }
})